package testBaGu;
import org.apache.commons.lang3.SerializationUtils;

import java.io.Serializable;

class Persons implements Serializable{
    String name;
    Addresses address;

    //通过序列化反序列化实现深拷贝
    protected Persons deepCopy(){
        return SerializationUtils.clone(this);
    }
}
class Addresses implements Serializable{
    String city;
}
public class DeepCopyExample {
    public static void main(String []args){
        Persons person1=new Persons();
        person1.name="John";
        person1.address=new Addresses();
        person1.address.city="New York";

        Persons person2=person1.deepCopy();

        System.out.println("完成老板输出4的功能");

        System.out.println("完成老板输出3的功能");


        System.out.println(person1==person2); // false
        System.out.println(person1.address==person2.address);
    }
}
